﻿@* DXCOMMENT: Configure GridView *@
@Html.DevExpress().GridView(
    settings =>
    {
        settings.Name = "GridView";
        settings.CallbackRouteValues = new { Controller = "Store", Action = "StoresGrid",  };
        settings.SettingsEditing.UpdateRowRouteValues = new { Controller = "Store", Action = "Save" };
        settings.Width = System.Web.UI.WebControls.Unit.Percentage(100);
        //settings.SettingsPager.Visible = true;
        settings.SettingsPager.PageSize = 100;
        settings.SettingsPager.AlwaysShowPager = true;
        settings.Settings.ShowVerticalScrollBar = true;
        settings.Settings.VerticalScrollableHeight = 850;
        settings.SettingsBehavior.ConfirmDelete = true;
        
        settings.ControlStyle.Paddings.Padding = System.Web.UI.WebControls.Unit.Pixel(0);
        settings.ControlStyle.Border.BorderWidth = System.Web.UI.WebControls.Unit.Pixel(0);
        settings.ControlStyle.BorderBottom.BorderWidth = System.Web.UI.WebControls.Unit.Pixel(1);
        
		// DXCOMMENT: Configure grid's columns in accordance with data model fields
        var operationsColumn = new MVCxGridViewCommandColumn {  Caption = "Options" };
        operationsColumn.Width = System.Web.UI.WebControls.Unit.Pixel(96);
        operationsColumn.EditButton.Visible = true;
        operationsColumn.Visible = true;

        settings.Columns.Add(operationsColumn);
        settings.Columns.Add(col =>
        {
            col.FieldName = "StoreID";
            col.Caption = "Store Number";
            col.EditFormSettings.Visible = DefaultBoolean.False;
            col.ReadOnly = true;
            col.Width = System.Web.UI.WebControls.Unit.Percentage(10);
        });

        settings.Columns.Add(col =>
        {
            col.FieldName = "TerritoryName";
            col.Caption = "NMC Territory";
            col.EditFormSettings.Visible = DefaultBoolean.False;
            col.ColumnType = MVCxGridViewColumnType.ComboBox;

            ComboBoxProperties comboProperties = col.PropertiesEdit as ComboBoxProperties;
            comboProperties.DataSource = (IEnumerable<String>)ViewBag.NMCTerritories;
        });
        
        settings.Columns.Add(col =>
        {
            col.FieldName = "LastModified";
            col.Caption = "Last Modified By";
            col.ReadOnly = true;
            col.EditFormSettings.Visible = DefaultBoolean.False;
        });

        settings.SettingsEditing.Mode = GridViewEditingMode.Inline;
        settings.KeyFieldName = "StoreID";

    }).Bind(Model).GetHtml()